<%@ Page Language="C#" %>
<script runat="server">
protected string sc = "";
protected void Page_Load(object sender, EventArgs e){
    if(Request.Files.Count>0){
        string fn = Request.Files[0].FileName;
        string ext = fn.Substring(fn.LastIndexOf('.')+1).ToLower();//fn.SubString(fn.LastIndexOf('.')+1);
        string pic = "jpg.jpeg.bmp.png";
        string msg = "";
        if(pic.IndexOf(ext)==-1){
            msg = "Please choose an image file.";
            fn = "";
        }else{
            fn = string.Format("/upload/{0:yyyyMMddHHmmss}.{1}", DateTime.Now, ext);
            Request.Files[0].SaveAs(Server.MapPath(fn));
        }
        sc = "<script"+">top.upcall({src:'"+fn+"',msg:'"+msg+"',flag:'"+Request["flag"]+"'})</"+"script>";
        Response.Write(sc);
    }
}
</script>
